Maple Tool1.mws

Maple Tool 1

This tool is designed to be used with Activity 1 in Section 10.3.1.

>    with(plots): with(stats[statplots]):
f:=x->exp(x);

Here are the first nine Taylor polynomials for the exponential function at x = 0 .

>    P[0]:=x->1;
P[1]:=x->P[0](x)+x;
P[2]:=x->P[1](x)+x^2/2;
P[3]:=x->P[2](x)+x^3/(3!);
P[4]:=x->P[3](x)+x^4/(4!);
P[5]:=x->P[4](x)+x^5/(5!);
P[6]:=x->P[5](x)+x^6/(6!);
P[7]:=x->P[6](x)+x^7/(7!);
P[8]:=x->P[7](x)+x^8/(8!);

Now we examine the convergence of the polynomial approximations at a particular point x[0] .  The following code will display a graph of the function f(x) , graphs of the first nine Taylor polynomial approximations P[n](x) , and the first nine Taylor approximations at the particular pont x[0] .

Enter a value of x[0]  between -4  and 4 .

>    x[0]:=?;

Below the plot we list the approximating values together with the value of f(x)  and the error in the last approximation.  The viewing window [-a .. a, -b .. b]  may be altered by varying the definitions of the constants a  and b .

>    a:=4; b:=60;
PlotA:=plot(f(x),x=-a..a, thickness=3, color=red, xtickmarks=[-a,-a/2,a/2,a], ytickmarks=[-b,-b/2,b/2,b], view=[-a..a,-b..b]):

>    xdata:=[x[0],x[0],x[0],x[0],x[0],x[0],x[0],x[0],x[0]]:
ydata:=[P[0](x[0]), P[1](x[0]), P[2](x[0]), P[3](x[0]),P[4](x[0]), P[5](x[0]), P[6](x[0]), P[7](x[0]), P[8](x[0])]:
PlotF:=scatterplot(xdata, ydata, color=navy):
PlotG:=plot([P[0](x), P[1](x), P[2](x), P[3](x), P[4](x), P[5](x), P[6](x), P[7](x), P[8](x)], x=-a..a, color=green, xtickmarks=[-a,-a/2,a/2,a], ytickmarks=[-b,-b/2,b/2,b], view=[-a..a,-b..b]):
display(PlotA,PlotF,PlotG);
print(Approximations);
evalf(ydata);

>    print(Actual); evalf(f(x[0]));

>    print(Actual-last_approximation);
evalf(f(x[0])-ydata[9]);

>   

>